//
//  CJCustomCountView.m
//  DatangLife
//
//  Created by 陈建 on 2018/5/7.
//  Copyright © 2018年 DatangLife. All rights reserved.
//

#import "CJCustomCountView.h"

@implementation CJCustomCountView

@synthesize reduceBtn,addBtn,countTextField,titleLable;

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        titleLable = [[UILabel alloc] init];
        titleLable.text = @"购买数量";
        titleLable.textColor = [UIColor colorWithHexString:kNomalTextBlackColor];
        titleLable.font = kFont(14.f);
        [self addSubview:titleLable];
        [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(kSize(15)));
            make.top.equalTo(@(kSize(10)));
            make.width.equalTo(@(kSize(100)));
            make.height.equalTo(@(kSize(30)));
        }];
        
        
        addBtn = [CJUIKit buttonWithBackgroundColor:kWhiteColor titleColorForNormal:kCommonRedColor titleForNormal:@"+" titleForSelete:nil titleColorForSelete:kCommonRedColor fontSize:20 font:nil];
        [CJUIKit viewcornerRadius:4 andColor:kCommonRedColor andWidth:1 onView:addBtn];
        [self addSubview:addBtn];
        [addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-kSize(15));
            make.width.height.equalTo(@(kSize(30)));
            make.centerY.equalTo(self);
        }];
        
        countTextField = [CJUIKit textFieldWithBackgroundColor:kWhiteColor textColor:[UIColor blackColor] secureTextEntry:NO fontSize:15 font:nil text:@"1" placeholder:nil textAlignment:NSTextAlignmentCenter];
        countTextField.enabled = NO;
        countTextField.borderStyle = UITextBorderStyleNone;
        [self addSubview:countTextField];
        [countTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(addBtn.mas_left).offset(-kSize(5));
            make.width.height.equalTo(@(kSize(20)));
            make.centerY.equalTo(self);
        }];
        
        reduceBtn = [CJUIKit buttonWithBackgroundColor:kWhiteColor titleColorForNormal:[UIColor colorWithHexString:kDetailTextBlackColor] titleForNormal:@"-" titleForSelete:nil titleColorForSelete:[UIColor colorWithHexString:kDetailTextBlackColor] fontSize:20 font:nil];
        [CJUIKit viewcornerRadius:4 andColor:[UIColor colorWithHexString:kDetailTextBlackColor] andWidth:1 onView:reduceBtn];
        [self addSubview:reduceBtn];
        [reduceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(countTextField.mas_left).offset(-kSize(5));
            make.width.height.equalTo(@(kSize(30)));
            make.centerY.equalTo(self);
        }];
        
        
    }
    return self;
}

@end
